#!/bin/python
# decimal binary octal hexadecimal
# 0b 0o 0x
# [2::]

# write all night

# autotesting

import sys


decimal_string = "0."
dot_string = "."
binary_string="01"
octal_string="01234567"
hexadecimal_string="0123456789ABCDEFabcdef"
digital_string="0123456789"

judge_num = ""
headflag = 0
while judge_num=="" and judge_num !="quit" :
    judge_num=input("please input a number: \n")
else:
    if judge_num == "quit":
        print("quit program")
        sys.exit()
    print(judge_num[0])
    print(judge_num[1:])
    print(judge_num[1::])
    if judge_num[0] == '-':
        headflag = 0
        minus_flag = 0
        minus_dot_flag = 0
        for number in judge_num[1::]: 
            if number in digital_string:
                minus_flag += 1
            elif number is dot_string:
                minus_dot_flag += 1
                if minus_dot_flag >= 2:
                    print("mulitiple dot symbol detected! Please recheck you inputing!")
                    sys.exit()
            else:
                print("wrong or unrecognize number type!")
                sys.exit()              
        else:
            print("this is a minus decimal number.")
            sys.exit()       
    b_headflag = 0
    o_headflag = 0
    x_headflag = 0
    nohead_flag = 0
    dot_headflag = 0
    if judge_num[0:2] == '0b':
        print("ok, binary head")
        b_headflag = 1
        headflag = 1
    elif judge_num[0:2] == '0o':
        print("ok, octal head")
        o_headflag = 1
        headflag = 1
    elif judge_num[0:2] == '0x':
        print("ok, hexadecimal head")
        x_headflag = 1
        headflag = 1
    elif judge_num[0] == dot_string:
        print("ok, dot decimal head")
        judge_num = '0' + judge_num
        print(judge_num)
        dot_headflag = 1
        headflag = 1
    elif judge_num[0:2] == decimal_string:
        print("ok, decimal head")
        dot_headflag = 1
        headflag = 1
    elif (not judge_num[0:2].isdigit()) and ( x_headflag + o_headflag + b_headflag + dot_headflag ) == 0:
        print(judge_num[0:2].isdigit())
        print("wrong head type!")
        sys.exit()
    else:
        headflag = 0
        i = 1
        for nohead_char in judge_num:           
            if nohead_char in digital_string:
                print("good, it's digital head")
                nohead_flag = 1   
            else:
                nohead_flag = 0
                break
            if  i > 2:
                break
            print (i)
            i += 1            
        else:
            print(len(judge_num),"hello")
            if len(judge_num)<=2 and nohead_flag != 0:
                print("this is a digital number but short than 3 digits")
                sys.exit()
                
    print(judge_num[0:2])
    print(judge_num[2::])

    b_flag = 0
    o_flag = 0
    h_flag = 0
    d_flag = 0
    dot_flag = 0
    special_flag = 0
    
    for char in judge_num[2::]:
        loop_flag = 0
        if headflag != 0 or nohead_flag !=0 :
            if char in  binary_string :
                b_flag += 1
            else:
                loop_flag += 1                   
            if char in octal_string :
                o_flag += 1
            else:
                loop_flag += 1      
            if char in hexadecimal_string :
                h_flag += 1
            else:
                loop_flag += 1
            if char in digital_string :
                d_flag += 1
            else:
                loop_flag += 1
            if char in dot_string:
                dot_flag += 1
            else:
                loop_flag += 1
        #print("loop_flag",loop_flag)
        if loop_flag == 5:
            special_flag = 1
        #print("special_flag",special_flag)            
        if  special_flag == 1 : 
            #loop_flag == 0 and ( b_flag + o_flag + h_flag + d_flag ) == 0 and dot_flag < 2          
            print("this is not a number")
            break
    else:
        print("h_flag",h_flag)
        print("o_flag",o_flag)
        print("b_flag",b_flag)
        print("d_flag",d_flag)
        print("dot_flag",dot_flag)
        if b_flag > 0 and ( 3 * b_flag - o_flag - d_flag - h_flag ) == 0 and headflag != 0 and b_headflag == 1 :
            print("this is a binary number")
        elif h_flag > 0 and (h_flag + 2 - len(judge_num)) == 0 and ( 2 * h_flag - o_flag - b_flag ) >= 0 and headflag != 0 and x_headflag == 1 :
            print("this is a hexadecimal number")
        elif o_flag > 0 and ( 2 * o_flag - h_flag - d_flag ) <= 0 and (o_flag + 2 - len(judge_num)) == 0 and headflag != 0 and o_headflag == 1 :
            print("this is a octal number")
        elif d_flag > 0 and ( 2 * d_flag - h_flag - o_flag ) >= 0 and nohead_flag == 1 and dot_flag == 0 :  
            print("this is a digital number")
        elif d_flag > 0 and ( 2 * d_flag - h_flag - o_flag ) >= 0 and dot_headflag == 1 :
            print("this is a decimal number")
        elif d_flag > 0 and ( 2 * d_flag - h_flag - o_flag ) >= 0 and nohead_flag == 1 and dot_flag == 1 :
            print("this is a decimal number but have a long integer part")
        else:
            print("wrong number range!")
